package com.he.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.he.dao.RoomPriceDao;
import com.he.entity.RoomPrice;
import com.he.event.constact.EventConstact;
import com.he.event.util.EventUtil;
import com.he.service.IRoomPriceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class RoomPriceServiceImpl extends ServiceImpl<RoomPriceDao, RoomPrice> implements IRoomPriceService{
    @Autowired
    private EventUtil eventUtil;

    /**
     * 修改了客房对象信息 - 调整了价格
     * @param entity
     * @return
     */
    @Override
    public boolean updateById(RoomPrice entity) {
        boolean falg = super.updateById(entity);
        //发送一个事件 - 修改了客房价格对象
        eventUtil.publishEvent(EventConstact.EVENT_HOTEL_PRICE_UPDATE, entity);
        return falg;
    }
}
